<!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">>
        <title></title>
    </head>
    <body>

    </body>
<!--第五周练习-->
    <?php
    /**
    * 商品类
    */
    class ShopProduct0{
        
        
    }
    $product1 = new ShopProduct0();
    $product2 = new ShopProduct0();

    var_dump($product1);
    var_dump($product2);

    class ShopProduct1{

        public  $title   = '商品名称';
        public  $producerName = '制造商';
        public  $place   = '产地';
        public  $price   = 0;
        private  $discount = 0;
        protected $sell  = 1;

        public function setName($str = ''){

            return $this->title = $str;

        }

        private function getdiscount($value){

            return $this->title = $value;

        }
    }

    $producer1 = new ShopProduct1();
    echo '<br />';

    echo $producer1->title;
    echo '<br />';

    echo $producer1->producerName;
    echo  '<br />';

    $producer1->setName('手机');
    echo $producer1->title;
    var_dump($producer1->title);
    echo  '<br />';

    /**
    * 构造函数，当实例化对象时自动调用，初始化类
    */
    class ShopProduct2 extends ShopProduct1//extends：继承，private类型不能继承
    {
        
        function __construct($title,$producerName,$place,$price,$discount )
        {
            $this->title         = $title;
            $this->producerName  = $producerName;
            $this->place         = $place;
            $this->price         = $price;
            $this->discount      = $discount;

        }
    }

    // $producer2 = new ShopProduct2();
    // $producer2->setName('手机');
    // echo $producer2->title;
    echo '<br />';

    $producer3 = new ShopProduct2('iphone7','china','fushikang',7999,0);
    var_dump($producer3->producerName);


    ?>
    </html>